<template>
  <div class="container">
    <el-dialog title="题目审核" :visible="showDialog" width="400px"  :show-close="true"  @close="del">
      <div style="height:119px">
        <el-row class="button">
          <el-radio v-model="checkData.chkState" label="1"
            >通过</el-radio
          >
          <el-radio v-model="checkData.chkState" label="2"
            >拒绝</el-radio
          >
        </el-row>
        <el-row>
          <el-input
            type="textarea"
            placeholder="请输入审核意见"
            :rows="2"
            v-model="checkData.chkRemarks"
          >
          </el-input>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="del">取 消</el-button>
        <el-button type="primary" @click="btnok">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'CheckS',
  data () {
    return {
      checkData: {
        chkState: '1', // 1 通过 2 不通过
        chkRemarks: '' // 审核备注
      }
    }
  },
  props: {
    showDialog: {
      type: Boolean,
      default: false
    },
    choicelist: {
      type: Object,
      required: true
    }
  },
  methods: {
    async btnok () {
      if (this.checkData.chkRemarks.trim().length === 0) {
        return this.$message.warning('请输入审核意见')
      } else {
        await choiceCheck({
          id: this.choicelist.id,
          chkState: +this.checkData.chkState,
          chkRemarks: this.checkData.chkRemarks

        })
        this.$parent.list()
        this.checkData = {
          chkState: '1', // 1 通过 2 不通过
          chkRemarks: '' // 审核备注
        }
        this.$parent.showDialog = false
        this.$message.success('审核完成')
      }
    },
    // 关闭组件
    async del () {
      this.checkData = {
        chkState: '1', // 1 通过 2 不通过
        chkRemarks: '' // 审核备注
      }
      this.$emit('update:showDialog', false)
    }
  }
}
</script>

<style scoped>
.container .button {
  margin-bottom: 25px;
  padding-top: 8px;
}

</style>
